package com.hxit.huaxiamelongarden.controller;

import cn.hutool.core.bean.BeanUtil;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import com.hxit.huaxiamelongarden.domin.dto.LikeDto;
import com.hxit.huaxiamelongarden.domin.vo.LikeVo;
import com.hxit.huaxiamelongarden.service.LikeService;
import com.hxit.huaxiamelongarden.utils.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName LikeController
 * @description LikeController
 * @Author 12694
 * @Date 2025/1/28 12:31
 * @Version 1.0
 **/

@RestController
@Slf4j
@RequestMapping("/like")
@Tag(name = "点赞管理", description = "点赞相关接口")
@ApiSort(1)
public class LikeController {

    @Autowired
    private LikeService likeService;

    @GetMapping("/list")
    @Operation(summary = "获取用户点赞列表", description = "根据用户ID查询用户的点赞记录")
    @ApiOperationSupport(order = 1)
    public Result selectLikesByUserId(
            @Parameter(description = "用户ID", required = true, example = "123")
            @RequestAttribute("userId") String userId) {
        log.info("获取用户点赞列表,userId:{}", userId);
        LikeDto likeDto = likeService.selectLikesByUserId(Integer.parseInt(userId));
        LikeVo likeVo = BeanUtil.copyProperties(likeDto, LikeVo.class);
        return Result.success(likeVo);
    }
}
